<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改单元信息')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-unit-edit" th:object="${sysUnit}">
            <input name="unitId" th:field="*{unitId}" type="hidden">
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">楼栋名称：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group">-->
<!--                        <select id="building" class="form-control" required>-->
<!--                            <option th:each="building:${building}" th:value="${building.buildingId}" th:text="${building.buildingName}" th:selected="${building.flag}"></option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">单元名称：</label>
                <div class="col-sm-8">
                    <input name="unitName" th:field="*{unitName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">单元面积：</label>
                <div class="col-sm-8">
                    <input name="unitArea" th:field="*{unitArea}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/unit";
        $("#form-unit-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-unit-edit").serializeArray();
                var buildingId = $.form.selectSelects("building");
                data.push({"name": "buildingId", "value": buildingId})
                $.operate.save(prefix + "/edit", data);
            }
        }

        $(function() {
            $('#building').select2({
                placeholder: "请选择楼栋",
                allowClear: true
            });
        })
    </script>
</body>
</html>